home *** CD-ROM | disk | FTP | other *** search
- // Hilites the text in the code sample
- // oStart - reference to start of block
- // sText - string to find and hilite
- function HiliteText(oStart, sText)
- {
-
- var oRng = document.body.createTextRange();
- oRng.moveToElementText(oStart);
- var oRngFixed = oRng.duplicate();
-
- if (typeof(HiliteText.tokens) == 'undefined')
- {
- HiliteText.tokens = new Array(1);
- }
- else
- {
- for (i = 0; i < HiliteText.tokens.length; i++)
- {
- if (HiliteText.tokens[i].m_sSectionID == oStart.id && HiliteText.tokens[i].m_sToken == sText)
- {
- return;
- }
- }
-
- HiliteText.tokens.length++;
- }
-
-
- while (oRng.findText(sText, 1000000, 6) && oRngFixed.inRange(oRng))
- {
- oRng.execCommand('bold');
- oRng.collapse(false);
- }
-
- HiliteText.tokens[HiliteText.tokens.length-1] = new CHilitedToken(oStart.id, sText);
-
- }
-
- // a tuple representing the id of the section and the token to be hilited
- // the object is stored in an array to prevent the code from running twice on the same section
- function CHilitedToken(sSectionID, sToken)
- {
- this.m_sSectionID = sSectionID;
- this.m_sToken = sToken;
- }
-
-
- // Toggles the display of the content contained within oCode
- // oCode - reference to code block
- // sToken - string to bolden
- function ToggleSample(oCode, sToken)
- {
- if (ShowHideSection(window.event.srcElement, 'Sample Code'))
- {
- HiliteText(oCode, sToken);
- }
- }
-
- // If hidden, show. If shown, hide. Modify the caption of the element appropriately
- // Returns true if showing on return, false if hidden on return
- function ShowHideSection(oHead, sText)
- {
- var bRet = false;
- var oChild = document.all(oHead.getAttribute('child', false));
-
- if (typeof(oChild) == null)
- {
- return bRet;
- }
-
- var sClass = oChild.className;
- var sAction = "Show";
- if (sClass == "collapsed")
- {
- sAction = "Hide";
- bRet = true; // we'll be showing upon return, so return true
- }
-
- sAction = sAction + ' ' + sText;
- oChild.className = (sClass == "collapsed" ? "expanded" : "collapsed");
- oHead.innerText = sAction;
- return bRet;
- }
-
- // Set the caption of the specified element
- // oElem - reference to element to modify. Typically a Hn
- // sCaption - New caption for the element
- // bShow - boolean indicating whether or not the element should be made visible
- function SetExpandableCaption(oElem, sCaption, bShow)
- {
- oElem.innerText = sCaption;
- if (bShow) oElem.style.display = 'inline';
- }
-
- // Set the caption for the TOC menu, and fix up the href. IE4 only
- function SetTOC()
- {
-
- // SetTOC is DISABLED for now. Delete the following line to enable it:
- return;
-
-
- var sProjectRoot1 = "/ds/";
- var sProjectRoot2 = "\\ds\\";
-
- // build a string for the 'Show Contents' case
- var sPath = location.pathname;
-
- var sMask = (location.href.indexOf('ttp://') > 0) ? sProjectRoot1 : sProjectRoot2;
-
- if (sPath.lastIndexOf(sMask) < 0) // doc isn't located under proper project
- {
- alert('\n\n\nMessage 001 generated by common.js script module in function SetTOC() .\n\n\nCurrent project location does not match expected mask settings.\nCurrent mask:\n sProjectRoot1: "' + sProjectRoot1 + '"\n or\n sProjectRoot2: "' + sProjectRoot2 + '"\n\n\n');
- return;
- }
-
- var iStart = sPath.lastIndexOf(sMask)+sMask.length;
- sFramed = sPath.substring(0,sPath.lastIndexOf(sMask)) +
- sMask+"c-frame.htm#" +
- (sPath.substring(iStart) == "" ? "default.htm" : sPath.substring(iStart));
-
- if (window.top == self)
- {
- location.href = sFramed;
- }
- }
-
- function resizeDocContents()
- {
- ; // document resize event handler
- }